<%@ page import="BL.User"%>
<%@ page import="BL.AccessDB"%>

<%
	User[] usr = AccessDB.getUser();
	HttpSession sess = request.getSession();
	boolean angemeldet = false;
	User formUser = null;
	boolean memberSelected = true;
%>



<h2>User verwalten:</h2>
<br>

<form method="post" action="centralServlet">
	<input type="hidden" name=act value="userVerwalten"></input>
	<table>
		<tr>
			<th>User</th>
			<td><input type="text" name="usr" id="usr"></input></td>
		</tr>
		<tr>
			<th>Passwort</th>
			<td><input type="text" name="pwd" id="pwd"></input></td>
		</tr>
		<tr>
			<th>Rolle</th>
			<td><select name="role">
					<%
						if (memberSelected) {
					%>
					<option selected="selected">Member</option>
					<option>Admin</option>
					<%
						} else {
					%>
					<option>Member</option>
					<option selected="selected">Admin</option>
					<%
						}
					%>
			</select></td>
		</tr>
	</table>
	<br>


	<script>
		
	<%//System.out.println("Testsdfsd");%>
		function selectList(value) {
			alert("Test");
		}
	</script>




	<input type="submit" name="userAct" value="User hinzufuegen"></input> <input
		type="submit" name="userAct" value="User bearbeiten"></input>


	<p>
	<p>
	<table>
		<tr>
			<th>Username</th>
			<th>Passwort</th>
			<th>Rolle</th>
			<th></th>
			<th></th>
		</tr>

		<%
			for (int x = 0; x < usr.length; x++) {
				out.println("<tr><td>" + usr[x].getUser() + "</td>");
				out.println("<td>" + usr[x].getPassword() + "</td>");
				out.println("<td>" + usr[x].getRole() + "</td>");
		%>
		<td><input type="hidden" name=act value="userVerwalten"></input>

			<input type="button" name="bearbeiten" value="Zur Bearbeitung"
			action=""
			onclick="this.form.usr.value='<%=usr[x].getUser()%>';this.form.pwd.value='<%=usr[x].getPassword()%>'">
		</td>
		<td><input type="submit" name="userAct" value="loeschen"
			onclick="this.form.usr.value='<%=usr[x].getUser()%>'"></input></td>
		</tr>



		<%
			}
		%>

	</table>
</form>

<%
	if (sess.getAttribute("fehler") != null) {
		if (sess.getAttribute("fehler") != "")
			out.print("<script>alert('" + sess.getAttribute("fehler")
					+ "');</script>");
	}
%>
